#include <iostream>
#include <algorithm>
// 5
using namespace std;
const int N = 1010;

int num[26];
int fz[26];
int main()
{
    string a;
    cin >> a;
    for(int i = 0;i < 26 ;i ++ )
    {
        scanf("%d",&fz[i]);
    }
    int sum = 0;
    for(int i = 0; i < a.size();i ++ )
    {
        num[a[i]-'a']++;
        sum = sum + fz[a[i]-'a'];
    }
    for(int i = 0 ; i < 26; i ++ )
    {
    	if(i<25) printf("%d ",num[i]);
    	else printf("%d",num[i]);
	}
    printf("\n");
    printf("%d",sum);
    return 0;
}
